/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.src.ptit.javatraining.huynh.btvn1;

/**
 *
 * @author user
 */
public class Baitap7 {

    public static int pt(long m) {
        int n = 0;
        while (m != 0) {
            n = (int) (n + m % 10);
            m /= 10;
        }
        return n;
    }

    public static void main(String[] args) {
        long a;
        long s1 = (long) Math.pow(10.0, 4);
        long s2;
        s2 = (long) Math.pow(10, 7);
        int b[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55};
        for (long i = s1; i <= s2; i++) {
            if ((Baitap1.isPrime(i) == true) && (Baitap6.reverse(i) == 1)) {
                int m = pt(i), ok = 0;
                for (int j = 1; j <= b.length - 1; j++) {
                    if (m == b[j]) {
                        ok = 1;
                        break;
                    }
                }
                if (ok == 1) {
                    System.out.println(i);
                }
            }

        }
    }
}
